#pragma once

#include <pthread.h>
#include <signal.h>

#include "Mutex.h"
#include "Condition.h"
#include "Thread.h"
#include "ThreadPool.h"
#include "Job.h"

class WorkerThread : public Thread
{
public:
    WorkerThread() : Thread(), m_pThreadPool(NULL), m_pJob(NULL), m_mutex(), m_cond() {}
    virtual ~WorkerThread() {}

    virtual void Run();

    virtual void SetJob(Job* pJob);
    virtual Job* GetJob();

    virtual void SetThreadPool(ThreadPool* pThreadPool);

    static void CleanupHandler(void* ptr);

private:
    ThreadPool* m_pThreadPool;
    Job* m_pJob;
    Mutex m_mutex;
    Condition m_cond;
};

